package itbour.onetouchshow.utils;

import android.text.format.Time;
import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by admin on 2016/7/7.
 */
public class DateUtils {

    private static final String TAG = "DateUtils";
    private static final String[] MOUTH_ARR = {"Jan.",
            "Feb.",
            "Mar.",
            "Apr.",
            "May.",
            "Jun.",
            "Jul.",
            "Aug.",
            "Sep.",
            "Oct.",
            "Nov.",
            "Dec."};
    private static SimpleDateFormat msFormat = new SimpleDateFormat("m:ss");

    public static String setNowTimeString() {
        int[] nowTime = getNowTime();
        int mounth = nowTime[0];
        int day = nowTime[1];
//        MOUTH_ARR[mounth]+day
        return MOUTH_ARR[mounth] + day + "";
    }

    public static int[] getNowTime() {
        Time time = new Time("GMT+8");
        time.setToNow();
        int month = time.month;
        int day = time.monthDay;

        Log.i(TAG, "getNowTime: " + month);
        return new int[]{month, day};
    }

    public static String getYMD() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        Date date = new Date(System.currentTimeMillis());
        return simpleDateFormat.format(date);
    }

    public static String timeParse(long duration) {
        String time = "";
        if (duration > 1000L) {
            time = timeParseMinute(duration);
        } else {
            long minute = duration / 60000L;
            long seconds = duration % 60000L;
            long second = (long) Math.round((float) seconds / 1000.0F);
            if (minute < 10L) {
                time = time + "0";
            }

            time = time + minute + ":";
            if (second < 10L) {
                time = time + "0";
            }

            time = time + second;
        }

        return time;
    }

    public static String timeParseMinute(long duration) {
        try {
            return msFormat.format(Long.valueOf(duration));
        } catch (Exception var3) {
            var3.printStackTrace();
            return "0:00";
        }
    }

    public static int dateDiffer(long d) {
        try {
            long l1 = Long.parseLong(String.valueOf(System.currentTimeMillis()).substring(0, 10));
            long interval = l1 - d;
            return (int) Math.abs(interval);
        } catch (Exception var6) {
            var6.printStackTrace();
            return -1;
        }
    }

    public static String cdTime(long sTime, long eTime) {
        long diff = eTime - sTime;
        return diff > 1000L ? diff / 1000L + "秒" : diff + "毫秒";
    }

    //
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//


}
